package com.magesti.tests;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;

import com.magesti.form.SuperForm;

public class TestTableauForm extends SuperForm{
	
	private String valeur1="vide1";
	private String description1="vide1";
	private String valeur2="vide2";
	private String description2="vide2";
	private String valeur3="vide2";
	private String description3="vide3";
	
	private static final String ATT_VALEUR = "valeur"; 
	private static final String ATT_DESCRIPTION = "description";
	private static final String ATT_NOMBRE_CHAMP = "nbChamp";
	
	public TestTableauForm(HttpServletRequest request) {
		ArrayList<String> tabValeur = new ArrayList<String>();
		
		int nbChamp;
		try{
		nbChamp = Integer.parseInt(getValeurChamp(request, ATT_NOMBRE_CHAMP));
		
		}catch(NumberFormatException e){
			System.out.println("Erreur de la methode parseInt:"+getValeurChamp(request, ATT_NOMBRE_CHAMP)+" n'est pas un String");
			nbChamp = 3;
		}
		
		
		for(int i=1; i<=nbChamp;i++)
		{
			String tabValue="["+i+"]";
			String v = getValeurChamp(request, ATT_VALEUR+tabValue);
			String d = getValeurChamp(request, ATT_DESCRIPTION+tabValue);
			tabValeur.add("Numero: "+i+" |Valeur="+v+"| description= "+d);
		}
		
		for(String s : tabValeur){
			System.out.println(s);
		}
		//valeur1 = getValeurChamp(request,);

		
	}

	public String getValeur1() {
		return valeur1;
	}

	public void setValeur1(String valeur1) {
		this.valeur1 = valeur1;
	}

	public String getDescription1() {
		return description1;
	}

	public void setDescription1(String description1) {
		this.description1 = description1;
	}

	public String getValeur2() {
		return valeur2;
	}

	public void setValeur2(String valeur2) {
		this.valeur2 = valeur2;
	}

	public String getDescription2() {
		return description2;
	}

	public void setDescription2(String description2) {
		this.description2 = description2;
	}

	public String getValeur3() {
		return valeur3;
	}

	public void setValeur3(String valeur3) {
		this.valeur3 = valeur3;
	}

	public String getDescription3() {
		return description3;
	}

	public void setDescription3(String description3) {
		this.description3 = description3;
	}

}
